package com.heima.admin.controller.v1;

import com.heima.admin.service.UserService;
import com.heima.api.admin.LoginControllerApi;
import com.heima.model.admin.dtos.UserDto;
import com.heima.model.admin.pojos.AdUser;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName UserController
 * @Description TODO
 * @Author AWei
 * @DATE 2021/4/10 21:21
 * @Version 1.0
 */
@RestController
@RequestMapping("/login")
public class LoginController implements LoginControllerApi {

    @Resource
    private UserService userService;

    /**
     * @param dto 登录用户信息对象
     * @return 登录结果
     * @Description admin登录功能
     */
    @Override
    @PostMapping("in")
    public ResponseResult login(@RequestBody UserDto dto) {
        return userService.login(dto);
    }

    /**
     * @param adUser 用户实体对象
     * @return 注册结果
     * @Description 注册功能
     */
    @Override
    @PostMapping("register")
    public ResponseResult register(@RequestBody AdUser adUser) {
        return userService.register(adUser);
    }
}
